# -*- coding: utf-8 -*-
import DBLink.dbHelp

dbHelp = DBLink.dbHelp


# 查询所有展厅信息
def _api_gallery_select_all(_request):
    '''
           /api/gallery.select.all
           功能：查询所有展厅信息
           编写：cgz
           :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""}}
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true,
           "TB_GalleryList": [{"GalleryNum": "A101", "GalleryCode": "co1", "GalleryName": "测试瓷砖店"}, {"GalleryNum": "A102", "GalleryCode": "co2", "GalleryName": "马桶马桶ddd"}]}
           :param  _respon["TB_GalleryList"]:返回集合
           :param _respon["GalleryNum"]:展厅编码
           :param _respon["GalleryCode"]:位置标识
           :param _respon["GalleryName"]:展厅名称
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strSqlSel = """
        SELECT
        T1.GalleryNum,T1.GalleryName,GalleryCode
        FROM
        gallery T1
        WHERE
        T1.IsUsing='1'
        ORDER BY T1.GalleryNum
    """
    returnstrSqlGetAll = dbHelp.Select(strSqlSel)
    _respon["IsError"] = returnstrSqlGetAll["IsError"]
    _respon["ErrorInfo"]["ErrorCode"] = returnstrSqlGetAll["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = returnstrSqlGetAll["ErrorMsg"]
    _respon["ReturnValue"] = returnstrSqlGetAll["ReturnValue"]
    _respon["TB_GalleryList"] = returnstrSqlGetAll["Value"]
    return _respon


# 修改---修改展厅编码对应的展厅名称
def _api_gallery_bycode_name_edit(_request):
    '''
           /api/gallery.bycode.name.edit
           功能：修改---修改展厅编码对应的展厅名称
           编写：cgz
           :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryName":"马桶马桶ddd","GalleryNum":"A102","GalleryName_Old":"A102"}
           :param _request["GalleryName"]: 展厅名称
           :param _request["GalleryNum"]: 展厅编码
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true}
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strSqluP = """
        UPDATE gallery T1
        SET T1.GalleryName='""" + str(_request["GalleryName"]) + """',
        T1.SubmitTime= DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s')
        WHERE GalleryNum='""" + str(_request["GalleryNum"]) + """'
        AND
        T1.IsUsing='1'
        AND
        T1.GalleryName='""" + str(_request["GalleryName_Old"]) + """'
    """
    returnstrSqlUp = dbHelp.Exec(strSqluP)
    _respon["IsError"] = returnstrSqlUp["IsError"]
    _respon["ErrorInfo"]["ErrorCode"] = returnstrSqlUp["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = returnstrSqlUp["ErrorMsg"]
    _respon["ReturnValue"] = returnstrSqlUp["ReturnValue"]
    return _respon


# 修改---展厅介绍信息
def _api_gallery_infor_edit(_request):
    '''
           /api/gallery.infor.edit
           功能：修改---展厅介绍信息
           编写：cgz
           :param _request ={"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryMessage":"测试描述","GalleryNum":"A102","GalleryMessage_Old":"随意测试类型ddddfffff"}
           :param _request["GalleryMessage"]: 展厅介绍
           :param _request["GalleryTheme"]: 展厅主题
           :param _request["GalleryTheme_Old"]: 旧展厅主题
           :param _request["GalleryNum"]: 展厅编码
           :param _request["GalleryMessage_Old"]: 旧展厅介绍
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true}
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strSqluP = """
        UPDATE gallery T1
        SET T1.GalleryMessage='""" + str(_request["GalleryMessage"]) + """',
        T1.SubmitTime=DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s'),
        T1.GalleryTheme='""" + str(_request["GalleryTheme"]) + """'
        WHERE GalleryNum='""" + str(_request["GalleryNum"]) + """'
        AND
        T1.IsUsing='1'
        AND
        T1.GalleryMessage='""" + str(_request["GalleryMessage_Old"]) + """'
        AND
        T1.GalleryTheme='""" + str(_request["GalleryTheme_Old"]) + """'
    """
    returnstrSqlUp = dbHelp.Exec(strSqluP)
    _respon["IsError"] = returnstrSqlUp["IsError"]
    _respon["ErrorInfo"]["ErrorCode"] = returnstrSqlUp["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = returnstrSqlUp["ErrorMsg"]
    _respon["ReturnValue"] = returnstrSqlUp["ReturnValue"]
    return _respon


# 添加---展厅图片
def _api_gallery_picture_add(_request):
    '''
           /api/gallery.picture.add
           功能：添加---展厅图片
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryNum":"test","ImgPath":"test","ImgRemark":"test","ImgType":1,"ImgName":"hehh"}
             :param _request["GalleryNum"]:展厅编号
                         :param _request["ImgPath"]:图片路径
                         :param _request["ImgRemark"]:图片备注
                         :param _request["ImgType"]:图片类别，1主图，2副图
                         :param _request["ImgName"]:图片名称
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true}

    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    objIdReturn = dbHelp.GetNewids("gallerypicturelist")
    if objIdReturn["Value"] == 0:
        _respon["IsError"] = objIdReturn["IsError"]
        _respon["ErrorInfo"]["ErrorCode"] = objIdReturn["ErrorCode"]
        _respon["ErrorInfo"]["ErrorMsg"] = objIdReturn["ErrorMsg"]
        _respon["ReturnValue"] = objIdReturn["ReturnValue"]
    else:
        strSqlB = """
                    INSERT INTO gallerypicturelist
                    (MainID,GalleryNum,ImgPath,ImgRemark,ImgType,UploadTime,ImgName,IsUsing)
                   VALUES(
                   '""" + objIdReturn["Value"] + """',
                  '""" + _request["GalleryNum"] + """',
                   '""" + _request["ImgPath"] + """',
                  '""" + _request["ImgRemark"] + """',
                  """ + str(_request["ImgType"]) + """,
                   DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s'),
                   '""" + str(_request["ImgName"]) + """',
                   '1'
                   )
                    """
        objReturnB = dbHelp.Exec(strSqlB)
        _respon["IsError"] = objReturnB["IsError"]
        _respon["ErrorInfo"]["ErrorCode"] = objReturnB["ErrorCode"]
        _respon["ErrorInfo"]["ErrorMsg"] = objReturnB["ErrorMsg"]
        _respon["ReturnValue"] = objReturnB["ReturnValue"]
    return _respon


# 查询---根据展厅编号查询展厅信息（展厅首页信息展示）
def _api_gallery_select_bycode(_request):
    '''
               /api/gallery.select.bycode
               功能：查询---根据展厅编号查询展厅信息（展厅首页信息展示）
               编写：zpp
                :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryNum":"test"}
                 :param _request["GalleryNum"]:展厅编号
               :return _respon ={"TBGalleryViewMain": [{"UploadTime": "2017-04-06 15:58:06", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155804.png", "ImgType": 2, "MainID": 9}],
                "GalleryName": "测试瓷砖店",
                "GalleryMessage": "介绍",
                "SubmitTime": "0000-00-00",
                "TBGalleryViewFuBig": [{"UploadTime": "2017-04-06 16:00:18", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406160015.png", "ImgType": 4, "MainID": 10}], "GalleryTheme": "主题标题", "GalleryCode": "co1", "ReturnValue": true,
                "TBGalleryViewLogo": [{"UploadTime": "2017-04-06 16:04:48", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406160446.png", "ImgType": 1, "MainID": 11}], "GalleryNum": "A101", "RowNum": 5, "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false,
                "TBGalleryViewFuSmall": [{"UploadTime": "2017-04-06 15:54:10", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155408.png", "ImgType": 3, "MainID": 8}, {"UploadTime": "2017-04-06 15:53:07", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155305.png", "ImgType": 3, "MainID": 7}]}
                         :param _respon["GalleryMessage"]:展厅介绍
                         :param _respon["GalleryName"]:展厅名称
                         :param _respon["GalleryTheme"]:展厅主题
                         :param _respon["GalleryNum"]:展厅编码
                         :param _respon["GalleryCode"]:展厅标识
                         :param _respon["SubmitTime"]:提交时间
                         :param _respon["RowNum"]:记录数
                         :param _respon["TBGalleryViewMain"]:主图类型
                         :param _respon["TBGalleryViewFuBig"]:幅图大类型
                         :param _respon["TBGalleryViewLogo"]:logo类型
                         :param _respon["TBGalleryViewFuSmall"]:幅图小类型
                                :param _respon["ImgName"]:图片名称
                                :param _respon["ImgPath"]:图片路径
                                :param _respon["ImgRemark"]:图片备注
                                 :param _respon["MainID"]:图片ID
                                :param _respon["ImgType"]:图片类型，1logo,2主图，3副小图，4副大图
                                :param _respon["UploadTime"]:上传时间
        '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}

    strsql = """
             SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d')as UploadTime
                FROM gallerypicturelist T1
                WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                AND T1.IsUsing =1
            """
    objReturn = dbHelp.Select(strsql)
    if objReturn["RowNum"] == 0:
        _respon["TBGalleryView"] = []
    else:
        strLogo = """
            SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
            FROM gallerypicturelist T1
            WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
            AND T1.IsUsing =1
            AND T1.ImgType='1'
            ORDER BY T1.UploadTime DESC
            limit 1
                """
        objReturnA = dbHelp.Select(strLogo)
        if objReturnA["RowNum"] != 0:
            _respon["TBGalleryViewLogo"] = objReturnA["Value"]
        else:
            _respon["TBGalleryViewLogo"] = []
        strMain = """
                      SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                    AND T1.IsUsing =1
                    AND T1.ImgType='2'
                    ORDER BY T1.UploadTime DESC
                        """
        objReturnB = dbHelp.Select(strMain)
        if objReturnB["RowNum"] != 0:
            _respon["TBGalleryViewMain"] = objReturnB["Value"]
        else:
            _respon["TBGalleryViewMain"] = []
        strFuS = """
                           SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                           FROM gallerypicturelist T1
                           WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                           AND T1.IsUsing =1
                           AND T1.ImgType='3'
                           ORDER BY T1.UploadTime ASC
                               """
        objReturnC = dbHelp.Select(strFuS)
        if objReturnC["RowNum"] != 0:
            _respon["TBGalleryViewFuSmall"] = objReturnC["Value"]
        else:
            _respon["TBGalleryViewFuSmall"] = []
        strFuBig = """
                                   SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                                   FROM gallerypicturelist T1
                                   WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                                   AND T1.IsUsing =1
                                   AND T1.ImgType='4'
                                   ORDER BY T1.UploadTime ASC
                                       """
        objReturnD = dbHelp.Select(strFuBig)
        if objReturnD["RowNum"] != 0:
            _respon["TBGalleryViewFuBig"] = objReturnD["Value"]
        else:
            _respon["TBGalleryViewFuBig"] = []

    _respon["RowNum"] = len(objReturn["Value"])
    strsql1 = """
                SELECT T2.GalleryNum,T2.GalleryName,T2.GalleryMessage,T2.GalleryTheme,T2.GalleryCode,date_format(T2.SubmitTime,'%Y-%m-%d')as SubmitTime
                FROM gallery T2
                WHERE T2.GalleryNum='""" + _request["GalleryNum"] + """'
                AND T2.IsUsing=1
                """
    objReturn = dbHelp.Select(strsql1)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    if objReturn["ReturnValue"] == True:
        _respon["GalleryNum"] = objReturn["Value"][0]["GalleryNum"]
        _respon["GalleryName"] = objReturn["Value"][0]["GalleryName"]
        _respon["GalleryMessage"] = objReturn["Value"][0]["GalleryMessage"]
        _respon["GalleryTheme"] = objReturn["Value"][0]["GalleryTheme"]
        _respon["GalleryCode"] = objReturn["Value"][0]["GalleryCode"]
        _respon["SubmitTime"] = objReturn["Value"][0]["SubmitTime"]
    else:
        pass
    return _respon


# 删除---删除展厅主页图片，展厅编号，图片ID，图片类型（1主图，2副图）
def _api_gallery_picture_delete(_request):
    '''
          /api/gallery.picture.delete
           功能：删除---删除展厅主页图片，展厅编号，图片ID，图片类型（1主图，2副图）
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"MainID":"test"}
             :param _request["MainID"]:图片ID
           :return _respon ={ "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}}], "IsError": false, "ReturnValue": true}

    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}

    strsql = """
            update gallerypicturelist T
            set T.IsUsing = 0
            where T.MainID = """ + str(_request["MainID"]) + """
         """
    objReturn = dbHelp.Exec(strsql)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    return _respon


#  添加--展厅信息
def _api_gallery_add(_request):
    '''
           /api/gallery.add
           功能：添加--展厅信息
           编写：cgz
           :param _request ={"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""}, "GalleryNum": "A1023133", "GalleryMessage": "测温使用", "GalleryName": "欧莱雅",
                                        "GalleryTheme": "我的主题", "GalleryCode": "我的标识"}
           :param _request["GalleryNum"]: 展厅编码
           :param _request["GalleryMessage"]: 展厅介绍
           :param _request["GalleryName"]: 展厅名称
           :param _request["GalleryTheme"]: 展厅主题
           :param _request["GalleryCode"]: 展厅标识
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true}
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strSqlSelect = """
        SELECT
        COUNT(*) as num
        FROM
        gallery
        WHERE
        IsUsing='1'
        AND
        GalleryNum='""" + str(_request["GalleryNum"]) + """'
    """
    returnstrSqlSelect = dbHelp.Select(strSqlSelect)
    if returnstrSqlSelect["Value"][0]["num"] == 0:
        strSqlIn = """
            INSERT INTO gallery
            (
            GalleryNum,
            GalleryMessage,
            GalleryName,
            SubmitTime,
            GalleryTheme,
            IsUsing,
            GalleryCode
            )
            VALUES
            (
           '""" + str(_request["GalleryNum"]) + """',
            '""" + str(_request["GalleryMessage"]) + """',
           '""" + str(_request["GalleryName"]) + """',
             DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s'),
            '""" + str(_request["GalleryTheme"]) + """',
            '1',
            '""" + str(_request["GalleryCode"]) + """'
            )
        """
        returnstrSqlIn = dbHelp.Exec(strSqlIn)
        _respon["IsError"] = returnstrSqlIn["IsError"]
        _respon["ErrorInfo"]["ErrorCode"] = returnstrSqlIn["ErrorCode"]
        _respon["ErrorInfo"]["ErrorMsg"] = returnstrSqlIn["ErrorMsg"]
        _respon["ReturnValue"] = returnstrSqlIn["ReturnValue"]
    else:
        _respon["IsError"] = True
        _respon["ErrorInfo"]["ErrorCode"] = 1
        _respon["ErrorInfo"]["ErrorMsg"] = "展厅编码已在使用！"
        _respon["ReturnValue"] = False
    return _respon


def _api_gallery_picture_information_edit(_request):
    '''
          /api/gallery.picture.information.edit
           功能：修改--展厅对应图片信息
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"MainID":"3","ImgName":"13","ImgRemark":"13","ImgName_Old":"12","ImgRemark_Old":"12"}

             :param _request["MainID"]:图片ID
             :param _request["ImgName"]:图片名称
             :param _request["ImgRemark"]:图片备注
             :param _request["ImgName_Old"]:图片名称旧
             :param _request["ImgRemark_Old"]:图片备注旧
           :return _respon ={ "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}}], "IsError": false, "ReturnValue": true}

    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strsql = """
            update gallerypicturelist T
            set T.ImgName = '""" + _request["ImgName"] + """',
            T.ImgRemark='""" + _request["ImgRemark"] + """',
            T.UploadTime= DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s')
            where T.MainID = '""" + _request["MainID"] + """'
            and (
                T.ImgName='""" + _request["ImgName_Old"] + """'
            and T.ImgRemark='""" + _request["ImgRemark_Old"] + """'
            )
         """
    objReturn = dbHelp.Exec(strsql)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    return _respon


# 查询---根据展厅标识查询展厅信息（展厅首页信息展示）
def _api_gallery_select_bygallerycode(_request):
    '''
           /api/gallery.select.bygallerycode
           功能：查询---根据展厅标识查询展厅信息（展厅首页信息展示）
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryCode":"90193027"}
             :param _request["GalleryCode"]:展厅标识
           :return _respon ={"GalleryMessage": "",
           "GalleryName": "东鹏",
           "SubmitTime": "2017-04-11",
               "TBGalleryViewMain": [{"UploadTime": "2017-04-11 14:53:03", "ImgName": "1", "ImgRemark": "11", "ImgPath": "ImageUp_ByShop/imgUp_2_20170411145304.png", "ImgType": 2, "MainID": 85}],
               "TBGalleryViewFuBig": [{"UploadTime": "2017-04-10 18:16:06", "ImgName": "big-2", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_4_20170410181606.png", "ImgType": 4, "MainID": 78}, {"UploadTime": "2017-04-10 18:16:21", "ImgName": "big-3", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_4_20170410181621.png", "ImgType": 4, "MainID": 79}], "GalleryTheme": "",
                "TBGalleryViewFuSmall": [{"UploadTime": "2017-04-10 18:16:45", "ImgName": "sm-4", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181645.png", "ImgType": 3, "MainID": 80}, {"UploadTime": "2017-04-10 18:17:00", "ImgName": "sm-5", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181700.png", "ImgType": 3, "MainID": 81}, {"UploadTime": "2017-04-11 14:21:28", "ImgName": "sm-71", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181732.png", "ImgType": 3, "MainID": 83}, {"UploadTime": "2017-04-11 14:21:33", "ImgName": "sm-61", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181714.png", "ImgType": 3, "MainID": 82}, {"UploadTime": "2017-04-11 14:53:48", "ImgName": "", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170411145349.png", "ImgType": 3, "MainID": 86}], "ReturnValue": true,
                "TBGalleryViewLogo": [{"UploadTime": "2017-04-11 14:50:47", "ImgName": "高仪的Logo", "ImgRemark": "高仪的Logo", "ImgPath": "ImageUp_ByShop/imgUp_1_20170411145047.png", "ImgType": 1, "MainID": 84}],
             "GalleryNum": "A210",
            "GalleryCode": "90193027", "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false}

                     :param _respon["GalleryMessage"]:展厅介绍
                     :param _respon["GalleryName"]:展厅名称
                     :param _respon["GalleryTheme"]:展厅主题
                     :param _respon["GalleryNum"]:展厅编码
                     :param _respon["GalleryCode"]:展厅标识
                     :param _respon["SubmitTime"]:提交时间
                     :param _respon["RowNum"]:记录数
                     :param _respon["TBGalleryViewMain"]:主图类型
                     :param _respon["TBGalleryViewFuBig"]:幅图大类型
                     :param _respon["TBGalleryViewLogo"]:logo类型
                     :param _respon["TBGalleryViewFuSmall"]:幅图小类型
                            :param _respon["ImgName"]:图片名称
                            :param _respon["ImgPath"]:图片路径
                            :param _respon["ImgRemark"]:图片备注
                             :param _respon["MainID"]:图片ID
                            :param _respon["ImgType"]:图片类型，1logo,2主图，3副小图，4副大图
                            :param _respon["UploadTime"]:上传时间
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strsql1 = """
               SELECT T2.GalleryNum,T2.GalleryName,T2.GalleryMessage,T2.GalleryTheme,T2.GalleryCode,date_format(T2.SubmitTime,'%Y-%m-%d')as SubmitTime
               FROM gallery T2
               WHERE T2.GalleryCode='""" + _request["GalleryCode"] + """'
               AND T2.IsUsing=1
               """
    objReturn = dbHelp.Select(strsql1)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    if objReturn["ReturnValue"] == True:
        _respon["GalleryNum"] = objReturn["Value"][0]["GalleryNum"]
        GalleryNumCode = objReturn["Value"][0]["GalleryNum"]
        _respon["GalleryName"] = objReturn["Value"][0]["GalleryName"]
        _respon["GalleryMessage"] = objReturn["Value"][0]["GalleryMessage"]
        _respon["GalleryTheme"] = objReturn["Value"][0]["GalleryTheme"]
        _respon["GalleryCode"] = objReturn["Value"][0]["GalleryCode"]
        _respon["SubmitTime"] = objReturn["Value"][0]["SubmitTime"]
        strsql = """
                 SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d')as UploadTime
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                    AND T1.IsUsing =1
                """
        objReturn = dbHelp.Select(strsql)
        if objReturn["RowNum"] == 0:
            _respon["TBGalleryViewMain"] = []
            _respon["TBGalleryViewFuBig"] = []
            _respon["TBGalleryViewLogo"] = []
            _respon["TBGalleryViewFuSmall"] = []
        else:
            strLogo = """
                    SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum= '""" + GalleryNumCode + """'
                    AND T1.IsUsing =1
                    AND T1.ImgType='1'
                    ORDER BY T1.UploadTime DESC
                    limit 1
                        """
            objReturnA = dbHelp.Select(strLogo)
            if objReturnA["RowNum"] != 0:
                _respon["TBGalleryViewLogo"] = objReturnA["Value"]
            else:
                _respon["TBGalleryViewLogo"] = []
            strMain = """
                              SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                            FROM gallerypicturelist T1
                            WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                            AND T1.IsUsing =1
                            AND T1.ImgType='2'
                            ORDER BY T1.UploadTime DESC
                                """
            objReturnB = dbHelp.Select(strMain)
            if objReturnB["RowNum"] != 0:
                _respon["TBGalleryViewMain"] = objReturnB["Value"]
            else:
                _respon["TBGalleryViewMain"] = []
            strFuS = """
                                   SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                                   FROM gallerypicturelist T1
                                   WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                                   AND T1.IsUsing =1
                                   AND T1.ImgType='3'
                                   ORDER BY T1.UploadTime ASC
                                       """
            objReturnC = dbHelp.Select(strFuS)
            if objReturnC["RowNum"] != 0:
                _respon["TBGalleryViewFuSmall"] = objReturnC["Value"]
            else:
                _respon["TBGalleryViewFuSmall"] = []
            strFuBig = """
                           SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime
                           FROM gallerypicturelist T1
                           WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                           AND T1.IsUsing =1
                           AND T1.ImgType='4'
                           ORDER BY T1.UploadTime ASC
                                               """
            objReturnD = dbHelp.Select(strFuBig)
            if objReturnD["RowNum"] != 0:
                _respon["TBGalleryViewFuBig"] = objReturnD["Value"]
            else:
                _respon["TBGalleryViewFuBig"] = []
    else:
        pass

    return _respon


# 查询---根据展厅编号查询展厅信息（展厅首页信息展示）V2
def _api_gallery_select_bycode_v2(_request):
    '''
               /api/gallery.select.bycode.v2
               功能：查询---根据展厅编号查询展厅信息（展厅首页信息展示）V2
               编写：zpp
                :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryNum":"test"}
                 :param _request["GalleryNum"]:展厅编号
               :return _respon ={"TBGalleryViewMain": [{"UploadTime": "2017-04-06 15:58:06", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155804.png", "ImgType": 2, "MainID": 9}],
                "GalleryName": "测试瓷砖店",
                "GalleryMessage": "介绍",
                "SubmitTime": "0000-00-00",
                "TBGalleryViewFuBig": [{"UploadTime": "2017-04-06 16:00:18", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406160015.png", "ImgType": 4, "MainID": 10}], "GalleryTheme": "主题标题", "GalleryCode": "co1", "ReturnValue": true,
                "TBGalleryViewLogo": [{"UploadTime": "2017-04-06 16:04:48", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406160446.png", "ImgType": 1, "MainID": 11}], "GalleryNum": "A101", "RowNum": 5, "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false,
                "TBGalleryViewFuSmall": [{"UploadTime": "2017-04-06 15:54:10", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155408.png", "ImgType": 3, "MainID": 8}, {"UploadTime": "2017-04-06 15:53:07", "ImgName": "测试瓷砖店LOGO", "ImgRemark": "测试瓷砖店LOGO", "ImgPath": "D:/ImageUp_A/imgUp_20170406155305.png", "ImgType": 3, "MainID": 7}]}
                         :param _respon["GalleryMessage"]:展厅介绍
                         :param _respon["GalleryName"]:展厅名称
                         :param _respon["GalleryTheme"]:展厅主题
                         :param _respon["GalleryNum"]:展厅编码
                         :param _respon["GalleryCode"]:展厅标识
                         :param _respon["SubmitTime"]:提交时间
                         :param _respon["RowNum"]:记录数
                         :param _respon["TBGalleryViewMain"]:主图类型
                         :param _respon["TBGalleryViewFuBig"]:幅图大类型
                         :param _respon["TBGalleryViewLogo"]:logo类型
                         :param _respon["TBGalleryViewFuSmall"]:幅图小类型
                                :param _respon["ImgName"]:图片名称
                                :param _respon["ImgPath"]:图片路径
                                :param _respon["ImgRemark"]:图片备注
                                 :param _respon["MainID"]:图片ID
                                :param _respon["ImgType"]:图片类型，1logo,2主图，3副小图，4副大图
                                :param _respon["UploadTime"]:上传时间
                                :param _respon["GoodsTypeID"]:类型ID
        '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}

    strsql = """
             SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d')as UploadTime,T1.GoodsTypeID
                FROM gallerypicturelist T1
                WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                AND T1.IsUsing =1
            """
    objReturn = dbHelp.Select(strsql)
    if objReturn["RowNum"] == 0:
        _respon["TBGalleryView"] = []
    else:
        strLogo = """
            SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
            FROM gallerypicturelist T1
            WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
            AND T1.IsUsing =1
            AND T1.ImgType='1'
            ORDER BY T1.UploadTime DESC
            limit 1
                """
        objReturnA = dbHelp.Select(strLogo)
        if objReturnA["RowNum"] != 0:
            _respon["TBGalleryViewLogo"] = objReturnA["Value"]
        else:
            _respon["TBGalleryViewLogo"] = []
        strMain = """
                      SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                    AND T1.IsUsing =1
                    AND T1.ImgType='2'
                    ORDER BY T1.UploadTime DESC
                        """
        objReturnB = dbHelp.Select(strMain)
        if objReturnB["RowNum"] != 0:
            _respon["TBGalleryViewMain"] = objReturnB["Value"]
        else:
            _respon["TBGalleryViewMain"] = []
        strFuS = """
                           SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                           FROM gallerypicturelist T1
                           WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                           AND T1.IsUsing =1
                           AND T1.ImgType='3'
                           ORDER BY T1.UploadTime ASC
                               """
        objReturnC = dbHelp.Select(strFuS)
        if objReturnC["RowNum"] != 0:
            _respon["TBGalleryViewFuSmall"] = objReturnC["Value"]
        else:
            _respon["TBGalleryViewFuSmall"] = []
        strFuBig = """
                                   SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                                   FROM gallerypicturelist T1
                                   WHERE T1.GalleryNum='""" + _request["GalleryNum"] + """'
                                   AND T1.IsUsing =1
                                   AND T1.ImgType='4'
                                   ORDER BY T1.UploadTime ASC
                                       """
        objReturnD = dbHelp.Select(strFuBig)
        if objReturnD["RowNum"] != 0:
            _respon["TBGalleryViewFuBig"] = objReturnD["Value"]
        else:
            _respon["TBGalleryViewFuBig"] = []

    _respon["RowNum"] = len(objReturn["Value"])
    strsql1 = """
                SELECT T2.GalleryNum,T2.GalleryName,T2.GalleryMessage,T2.GalleryTheme,T2.GalleryCode,date_format(T2.SubmitTime,'%Y-%m-%d')as SubmitTime
                FROM gallery T2
                WHERE T2.GalleryNum='""" + _request["GalleryNum"] + """'
                AND T2.IsUsing=1
                """
    objReturn = dbHelp.Select(strsql1)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    if objReturn["ReturnValue"] == True:
        _respon["GalleryNum"] = objReturn["Value"][0]["GalleryNum"]
        _respon["GalleryName"] = objReturn["Value"][0]["GalleryName"]
        _respon["GalleryMessage"] = objReturn["Value"][0]["GalleryMessage"]
        _respon["GalleryTheme"] = objReturn["Value"][0]["GalleryTheme"]
        _respon["GalleryCode"] = objReturn["Value"][0]["GalleryCode"]
        _respon["SubmitTime"] = objReturn["Value"][0]["SubmitTime"]
    else:
        pass
    return _respon

# 查询---根据展厅标识查询展厅信息（展厅首页信息展示）V2
def _api_gallery_select_bygallerycode_v2(_request):
    '''
           /api/gallery.select.bygallerycode.v2
           功能：查询---根据展厅标识查询展厅信息（展厅首页信息展示）V2
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryCode":"90193027"}
             :param _request["GalleryCode"]:展厅标识
           :return _respon ={"GalleryMessage": "",
           "GalleryName": "东鹏",
           "SubmitTime": "2017-04-11",
               "TBGalleryViewMain": [{"UploadTime": "2017-04-11 14:53:03", "ImgName": "1", "ImgRemark": "11", "ImgPath": "ImageUp_ByShop/imgUp_2_20170411145304.png", "ImgType": 2, "MainID": 85,"GoodsTypeID":1}],
               "TBGalleryViewFuBig": [{"UploadTime": "2017-04-10 18:16:06", "ImgName": "big-2", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_4_20170410181606.png", "ImgType": 4, "MainID": 78,"GoodsTypeID":1}, {"UploadTime": "2017-04-10 18:16:21", "ImgName": "big-3", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_4_20170410181621.png", "ImgType": 4, "MainID": 79,"GoodsTypeID":1}], "GalleryTheme": "",
                "TBGalleryViewFuSmall": [{"UploadTime": "2017-04-10 18:16:45", "ImgName": "sm-4", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181645.png", "ImgType": 3, "MainID": 80,"GoodsTypeID":1}, {"UploadTime": "2017-04-10 18:17:00", "ImgName": "sm-5", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181700.png", "ImgType": 3, "MainID": 81}, {"UploadTime": "2017-04-11 14:21:28", "ImgName": "sm-71", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181732.png", "ImgType": 3, "MainID": 83}, {"UploadTime": "2017-04-11 14:21:33", "ImgName": "sm-61", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170410181714.png", "ImgType": 3, "MainID": 82}, {"UploadTime": "2017-04-11 14:53:48", "ImgName": "", "ImgRemark": "", "ImgPath": "ImageUp_ByShop/imgUp_3_20170411145349.png", "ImgType": 3, "MainID": 86 ,"GoodsTypeID":1}], "ReturnValue": true,
                "TBGalleryViewLogo": [{"UploadTime": "2017-04-11 14:50:47", "ImgName": "高仪的Logo", "ImgRemark": "高仪的Logo", "ImgPath": "ImageUp_ByShop/imgUp_1_20170411145047.png", "ImgType": 1, "MainID": 84,"GoodsTypeID":1}],
             "GalleryNum": "A210",
            "GalleryCode": "90193027", "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false}

                     :param _respon["GalleryMessage"]:展厅介绍
                     :param _respon["GalleryName"]:展厅名称
                     :param _respon["GalleryTheme"]:展厅主题
                     :param _respon["GalleryNum"]:展厅编码
                     :param _respon["GalleryCode"]:展厅标识
                     :param _respon["SubmitTime"]:提交时间
                     :param _respon["RowNum"]:记录数
                     :param _respon["TBGalleryViewMain"]:主图类型
                     :param _respon["TBGalleryViewFuBig"]:幅图大类型
                     :param _respon["TBGalleryViewLogo"]:logo类型
                     :param _respon["TBGalleryViewFuSmall"]:幅图小类型
                            :param _respon["ImgName"]:图片名称
                            :param _respon["ImgPath"]:图片路径
                            :param _respon["ImgRemark"]:图片备注
                             :param _respon["MainID"]:图片ID
                            :param _respon["ImgType"]:图片类型，1logo,2主图，3副小图，4副大图
                            :param _respon["UploadTime"]:上传时间
                            :param _respon["GoodsTypeID"]:类型ID
    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strsql1 = """
               SELECT T2.GalleryNum,T2.GalleryName,T2.GalleryMessage,T2.GalleryTheme,T2.GalleryCode,date_format(T2.SubmitTime,'%Y-%m-%d')as SubmitTime
               FROM gallery T2
               WHERE T2.GalleryCode='""" + _request["GalleryCode"] + """'
               AND T2.IsUsing=1
               """
    objReturn = dbHelp.Select(strsql1)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    if objReturn["ReturnValue"] == True:
        _respon["GalleryNum"] = objReturn["Value"][0]["GalleryNum"]
        GalleryNumCode = objReturn["Value"][0]["GalleryNum"]
        _respon["GalleryName"] = objReturn["Value"][0]["GalleryName"]
        _respon["GalleryMessage"] = objReturn["Value"][0]["GalleryMessage"]
        _respon["GalleryTheme"] = objReturn["Value"][0]["GalleryTheme"]
        _respon["GalleryCode"] = objReturn["Value"][0]["GalleryCode"]
        _respon["SubmitTime"] = objReturn["Value"][0]["SubmitTime"]
        strsql = """
                 SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d')as UploadTime,T1.GoodsTypeID
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                    AND T1.IsUsing =1
                """
        objReturn = dbHelp.Select(strsql)
        if objReturn["RowNum"] == 0:
            _respon["TBGalleryViewMain"] = []
            _respon["TBGalleryViewFuBig"] = []
            _respon["TBGalleryViewLogo"] = []
            _respon["TBGalleryViewFuSmall"] = []
        else:
            strLogo = """
                    SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                    FROM gallerypicturelist T1
                    WHERE T1.GalleryNum= '""" + GalleryNumCode + """'
                    AND T1.IsUsing =1
                    AND T1.ImgType='1'
                    ORDER BY T1.UploadTime DESC
                    limit 1
                        """
            objReturnA = dbHelp.Select(strLogo)
            if objReturnA["RowNum"] != 0:
                _respon["TBGalleryViewLogo"] = objReturnA["Value"]
            else:
                _respon["TBGalleryViewLogo"] = []
            strMain = """
                              SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                            FROM gallerypicturelist T1
                            WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                            AND T1.IsUsing =1
                            AND T1.ImgType='2'
                            ORDER BY T1.UploadTime DESC
                                """
            objReturnB = dbHelp.Select(strMain)
            if objReturnB["RowNum"] != 0:
                _respon["TBGalleryViewMain"] = objReturnB["Value"]
            else:
                _respon["TBGalleryViewMain"] = []
            strFuS = """
                                   SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                                   FROM gallerypicturelist T1
                                   WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                                   AND T1.IsUsing =1
                                   AND T1.ImgType='3'
                                   ORDER BY T1.UploadTime ASC
                                       """
            objReturnC = dbHelp.Select(strFuS)
            if objReturnC["RowNum"] != 0:
                _respon["TBGalleryViewFuSmall"] = objReturnC["Value"]
            else:
                _respon["TBGalleryViewFuSmall"] = []
            strFuBig = """
                           SELECT T1.ImgName,T1.ImgPath,T1.ImgRemark,T1.ImgType,T1.MainID,date_format(T1.UploadTime,'%Y-%m-%d %H:%i:%s')as UploadTime,T1.GoodsTypeID
                           FROM gallerypicturelist T1
                           WHERE T1.GalleryNum='""" + GalleryNumCode + """'
                           AND T1.IsUsing =1
                           AND T1.ImgType='4'
                           ORDER BY T1.UploadTime ASC
                                               """
            objReturnD = dbHelp.Select(strFuBig)
            if objReturnD["RowNum"] != 0:
                _respon["TBGalleryViewFuBig"] = objReturnD["Value"]
            else:
                _respon["TBGalleryViewFuBig"] = []
    else:
        pass

    return _respon

# 添加---展厅图片V2
def _api_gallery_picture_add_v2(_request):
    '''
           /api/gallery.picture.add.v2
           功能：添加---展厅图片V2
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"GalleryNum":"test","ImgPath":"test","ImgRemark":"test","ImgType":1,"ImgName":"hehh","GoodsTypeID":"1"}
             :param _request["GalleryNum"]:展厅编号
                         :param _request["ImgPath"]:图片路径
                         :param _request["ImgRemark"]:图片备注
                         :param _request["ImgType"]:图片类别，1主图，2副图
                         :param _request["ImgName"]:图片名称
                         :param _request["GoodsTypeID"]:类型ID
           :return _respon ={"ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}, "IsError": false, "ReturnValue": true}

    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    objIdReturn = dbHelp.GetNewids("gallerypicturelist")
    if objIdReturn["Value"] == 0:
        _respon["IsError"] = objIdReturn["IsError"]
        _respon["ErrorInfo"]["ErrorCode"] = objIdReturn["ErrorCode"]
        _respon["ErrorInfo"]["ErrorMsg"] = objIdReturn["ErrorMsg"]
        _respon["ReturnValue"] = objIdReturn["ReturnValue"]
    else:
        strSqlB = """
                    INSERT INTO gallerypicturelist
                    (MainID,GalleryNum,ImgPath,ImgRemark,ImgType,UploadTime,GoodsTypeID,ImgName,IsUsing)
                   VALUES(
                   '""" + objIdReturn["Value"] + """',
                  '""" + _request["GalleryNum"] + """',
                   '""" + _request["ImgPath"] + """',
                  '""" + _request["ImgRemark"] + """',
                  """ + str(_request["ImgType"]) + """,
                   DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s'),
                  '""" + str(_request["GoodsTypeID"]) + """',
                   '""" + str(_request["ImgName"]) + """',
                   '1'
                   )
                    """
        objReturnB = dbHelp.Exec(strSqlB)
        _respon["IsError"] = objReturnB["IsError"]
        _respon["ErrorInfo"]["ErrorCode"] = objReturnB["ErrorCode"]
        _respon["ErrorInfo"]["ErrorMsg"] = objReturnB["ErrorMsg"]
        _respon["ReturnValue"] = objReturnB["ReturnValue"]
    return _respon


#修改--展厅对应图片信息v2
def _api_gallery_picture_information_edit_v2(_request):
    '''
          /api/gallery.picture.information.edit.v2
           功能：修改--展厅对应图片信息V2
           编写：zpp
            :param _request = {"RequestBaseHeader": {"SeesionKey": "", "TimeSpan": ""},"MainID":"3","ImgName":"13","ImgRemark":"13","ImgName_Old":"12","ImgRemark_Old":"12","GoodsTypeID":"12","GoodsTypeID_Old":"10"}

             :param _request["MainID"]:图片ID
             :param _request["ImgName"]:图片名称
             :param _request["ImgRemark"]:图片备注
             :param _request["ImgName_Old"]:图片名称旧
             :param _request["ImgRemark_Old"]:图片备注旧
             :param _request["GoodsTypeID"]:类型ID
             :param _request["GoodsTypeID_Old"]:旧类型ID
           :return _respon ={ "ErrorInfo": {"ErrorCode": 0, "ErrorMsg": ""}}], "IsError": false, "ReturnValue": true}

    '''
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": ""}
    strsql = """
            update gallerypicturelist T
            set T.ImgName = '""" + _request["ImgName"] + """',
            T.ImgRemark='""" + _request["ImgRemark"] + """',
            T.GoodsTypeID='""" + _request["GoodsTypeID"] + """',
            T.UploadTime= DATE_FORMAT(now(),'%Y-%m-%d %H:%i:%s')
            where T.MainID = '""" + _request["MainID"] + """'
            and (
                T.ImgName='""" + _request["ImgName_Old"] + """'
            and T.ImgRemark='""" + _request["ImgRemark_Old"] + """'
            and T.GoodsTypeID='""" + _request["GoodsTypeID_Old"] + """'
            )
         """
    objReturn = dbHelp.Exec(strsql)
    _respon["ErrorInfo"]["ErrorCode"] = objReturn["ErrorCode"]
    _respon["ErrorInfo"]["ErrorMsg"] = objReturn["ErrorMsg"]
    _respon["IsError"] = objReturn["IsError"]
    _respon["ReturnValue"] = objReturn["ReturnValue"]
    return _respon